﻿
Imports System.IO
Imports xhtmlctrl

Public Class inlineStyle
    Inherits inlineResource

    Public Const defaultType As String = network.http.contentType.textcss

    Public Sub New(Optional ByVal buff As Stream = Nothing)
        MyBase.New(buff)
    End Sub

    Public Function addstyle(ByVal type As String, ByVal name As String, ByVal content As String, _
                             Optional ByVal crunch As Boolean = False) As Boolean
        If crunch Then
            csscrunch(content)
        End If
        Return addresource(type, name, content)
    End Function

    Public Function addstyle(ByVal name As String, ByVal content As String, _
                             Optional ByVal crunch As Boolean = False) As Boolean
        Return addstyle(defaultType, name, content, crunch)
    End Function

    Public Shared Function registerStyle(ByVal type As String, ByVal name As String, ByVal content As String, _
                                         Optional ByVal crunch As Boolean = False) As Boolean
        If crunch Then
            csscrunch(content)
        End If

        Return registerResource(type, name, content)
    End Function

    Public Shared Function registerStyle(ByVal name As String, ByVal content As String, _
                                         Optional ByVal crunch As Boolean = False) As Boolean
        Return registerStyle(defaultType, name, content, crunch)
    End Function

    Public Function addRegisteredStyle(ByVal type As String, ByVal name As String) As Boolean
        Return addRegisteredResource(type, name)
    End Function

    Public Function addRegisteredStyle(ByVal name As String) As Boolean
        Return addRegisteredStyle(defaultType, name)
    End Function

    Protected Overrides Function generateInstance() As xhtmlControl
        Return New style(output())
    End Function
End Class
